clear all; 
close all; clc

addpath('functions')
startupSM();

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This code solves the full model presented in Online Appendix D of Gagnon and Jeanneret (2022): 
%  "How Does Corporate Governance Impact Equity Volatility? Worldwide Evidence and Theory"
%  It generates the Figures A.1-3 of the Online Appendix.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% Parameter values  

parameters.X0       = 1;      % Initial cash flow level
parameters.X        = 1;      % Date-t cash flow level
parameters.sigma    = 0.30;   % Cash flow volatility
parameters.mu       = 0.03;   % Cash flow growth rate
parameters.r        = 0.04;   % Risk-free rate
parameters.tau      = 0.15;   % Corporate tax rate
parameters.alpha    = 0.75;   % Liquidation cost in default
parameters.psi      = 0.1;    % Manager's equity ownership
parameters.theta    = 10;     % Degree of corporate governance
    
%% Base case calibration

[equity_volatility, leverage, credit_spread, debt_coupon, default_boundary, firm_value, equity_value, expropriation_benefits] = corpo_static(parameters);
   
fprintf('\n ************************************************************\n\n')
disp(['  Output of the baseline calibration: '])
fprintf('\n ************************************************************\n\n')
fprintf('Equity volatility (in pct)\n'); fprintf('%12.1f \n', equity_volatility);
fprintf('Financial leverage (in pct)\n'); fprintf('%12.1f \n', leverage);
fprintf('Expropriation benefits \n'); fprintf('%12.2f \n', 100*expropriation_benefits);    
fprintf('\n')


%% Figures
    
% Create Figures A.2 and A.3 of the online Appendix
GJ_figuresA2_A3(parameters)

% Create Figure A.4 of the online Appendix
GJ_figureA4(parameters)


